#!/bin/bash
# AI测试用例生成智能体 - Linux/Mac启动脚本

echo "========================================"
echo "  AI测试用例生成智能体"
echo "========================================"
echo ""

# 检查Python是否安装
if ! command -v python3 &> /dev/null; then
    echo "[错误] 未检测到Python3，请先安装Python 3.8+"
    exit 1
fi

echo "[1/3] 检查依赖包..."
if ! python3 -c "import streamlit" &> /dev/null; then
    echo "[提示] 检测到缺少依赖，开始安装..."
    pip3 install -r requirements.txt
fi

echo ""
echo "[2/3] 检查配置文件..."
if [ ! -f "config/config.yaml" ]; then
    echo "[警告] 未找到config.yaml，正在从示例文件复制..."
    cp config/config.yaml.example config/config.yaml
    echo ""
    echo "[重要] 请先编辑 config/config.yaml 文件，填写您的API密钥！"
    echo ""
    exit 0
fi

echo ""
echo "[3/3] 启动应用..."
echo ""
echo "浏览器将自动打开应用界面（默认地址: http://localhost:8501）"
echo "按 Ctrl+C 可停止应用"
echo ""

streamlit run app.py

